<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>订单管理 - 管理后台</title>
    <link rel="stylesheet" href="/static/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/public.css" media="all"/>
</head>
<body class="childrenBody">
<div class="layui-col-md12">
    <form class="layui-form " action="" method="get">
        <blockquote class="layui-elem-quote title">
            <span class="layui-breadcrumb">
                <a href="javascript:void(0);">订单管理</a>
                <a><cite>课程订单</cite></a>
            </span>
            <div class="layui-inline">
                <label class="layui-form-label">搜索</label>
                <div class="layui-input-inline">
                    <input name="transaction" value="" class="layui-input" placeholder="请输入订单号"/>
                </div>
                <div class="layui-input-inline">
                    <input name="name" value="" class="layui-input" placeholder="请输入课程名称"/>
                </div>
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1">搜索</button>
            </div>
        </blockquote>
    </form>
    <table id="orderList" lay-filter="orderList" class="layui-table"></table>
    <script type="text/html" id="orderListTBar">
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">详情</a>
    </script>
    <script type="text/html" id="orderImage">
        <img src="/{{ d.course_image }}" style="height:30px;"/>
    </script>
</div>
<script src="/static/layui.js"></script>
<script>
    layui.use(['element', 'jquery', 'layer', 'table', 'form'], function () {
        var element=layui.element,
            layer = layui.layer,
            $ = layui.jquery,
            table = layui.table,
            form = layui.form;
        form.on('submit(demo1)', function(data){
            table.reload('orderListTable', {
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });
        layui.tableIns = table.render({
            elem: '#orderList',
            url: '{:url("order/lists")}',
            cellMinWidth: 95,
            page: true,
            limit: 15,
            limits: [15, 20, 30, 50],
            id: "orderListTable",
            cols: [[
                {field: 'transaction', title: '订单号', width: 200, align: "center"},
                {field: 'course_name', title: '课程', align: "center"},
                {field: 'course_image', templet: '#orderImage', title: '课程图片', width: 200, align: "center"},
                {field: 'course_price', title: '课程价格（元）', width: 150, align: "center"},
                {field: 'num', title: '人数', width: 80, align: "center"},
                {field: 'price', title: '订单价格', width: 100, align: "center"},
                {field: 'create_time', title: '下单时间', width: 200, align: "center"},
                {
                    field: 'pay_time', title: '支付时间', width: 200, align: "center", templet: function (d) {
                        return d.status == 1 ?  d.pay_time : '未支付';
                    }
                },
                {title: '操作', templet: '#orderListTBar', fixed: 'right', width: 150, align: 'center'}
            ]]
        });
        $('.childrenBody').on('click', 'img', function () {
            var img = new Array;
            img.push({src: $(this).attr('src')});
            layer.photos({
                photos: {data: img},
                anim: 5
            });
        });
        table.on('tool(orderList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'edit') {
                var index = layui.layer.open({
                    title: "编辑订单",
                    type: 2,
                    content: "{:url('order/editOrder')}?id=" + data.order_id,
                    area: ['100%', '100%']
                });
            }
        });
    });
</script>
</body>
</html>